# ---- Caption and Heading of File ---------------------------------------------
#                                                                              #
#        Replication script for creating Figure 2.                             #
#        Not called directly, is a subroutine.                                 #
#                                                                              #
################################################################################



guilty.vote <- readPNG(source="images/icon-person.png")
guilty.vote.pull <- readPNG(source="images/g-person-pull.png")
notguilty.vote <- readPNG(source="images/icon-person2.png")
icon_height <- 48
icon_width <- 48

  par(mfrow=c(1, 1), mar=c(0,0,0,0), omi=c(0,0,0,0), family="serif")
  scale_factor <- .10
  ybottom <- 0
  
  plot(x="", y="", xlim=c(5, 135), ylim=c(-15, 12), axes=F, xlab="", ylab="")
  rect(xleft = 56.5, ybottom = -6, xright = 78.5, ytop = 8, lty = 1, col = "gray95")
  # segments(x0 = 5, x1 = 130, y0 = 1.5, y1 = 1.5, lty=1, lwd=2)
  segments(x0 = 67.5, y0 = -1.75, x1 = 67.5, y1 = 5.75, col = "black", lty=3)
  
  xlefts <- c(10, 20, 30, 40, 50, 60) 
  rasterImage(guilty.vote, xleft = xlefts, xright = xlefts + scale_factor*icon_width, 
              ybottom = ybottom, ytop = ybottom + scale_factor*icon_height)
  
  xlefts <- c(70, 80, 90, 100, 110, 120)
  rasterImage(notguilty.vote, xleft = xlefts, xright = xlefts + scale_factor*icon_width, 
              ybottom = ybottom, ytop = ybottom + scale_factor*icon_height)
  text(x=32.5, y=-3.5, label="\nExternal Influence:\nPull of guilty verdict faction", cex=.8)
  arrows(x0 = 52.5, x1 = 5, y0 = -2, y1 = -2, lty=1, lwd=1.5, code = 2, length = .1)
  points(x=52.5, y=-2, pch=16, cex=1)
  
  xlefts = 85
  ybottom = -10
  scale_factor = .075
  rasterImage(guilty.vote, xleft = xlefts, xright = xlefts + scale_factor*icon_width, 
              ybottom = ybottom, ytop = ybottom + scale_factor*icon_height)
  text(x=96.5, y=-7, label="= Guilty vote", pos=1, cex=.8)
  xlefts = 108
  rasterImage(notguilty.vote, xleft = xlefts, xright = xlefts + scale_factor*icon_width, 
              ybottom = ybottom, ytop = ybottom + scale_factor*icon_height)
  text(x=122, y=-7, label="= Not guilty vote", pos=1, cex=.8)
  
  text(x=67.5, y=8.5, label="Personal Factors:", pos=1, cex=.7)
  text(x=67.5, y=-1.5, label="Jurors on the fence:\nStay or switch sides?", 
       pos=1, cex=.7)
  
  text(x=72.5, y=3.1, label="?", col="black", cex=.7, font=2)
  text(x=62.5, y=3.1, label="?", col="white", cex=.7, font=2)




